<!DOCTYPE html>
<html>
<head>
    <title>新冠疫情最新动态</title>
    <meta charset="utf-8">
    <script src="/static/js/echarts.min.js"></script>
    <script src="/static/js/jquery-3.4.1.min.js"></script>
    <script src="/static/js/china.js"></script>
    <script src="/static/js/dataTool.js"></script>
  <style>
        *{margin:0;padding:0}
        html,body{
            width:100%;
            height:100%;
        }

        #report_area {
              width:600px;
              height:450px;
              margin: 25px auto;
              border:1px solid #ddd;
          }

        #total_line {
          width:600px;
          height:450px;
          margin: 25px auto;
          border:1px solid #ddd;
        }
    </style>


</head>
<body>
<h1 style="text-align:center">盗版疫情实时追踪</h1>
<p style="float: right;">(数据为真实数据截取自腾讯by杨锦)</p>

<div id="report_area" style="width: 800px; height: 600px;"></div>
<br>
<br>
<div id="add_data_area" style="width: 800px; height: 300px;"></div>


<script>
    let add_data_report = echarts.init(document.getElementById("add_data_area"));
    $.get('/get_add_data/',function(data){
            let option = {
            title: {
                text: '全国疫情新增趋势'
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                data: ['新增确诊', '新增疑似', '新增死亡', '新增治愈']
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            toolbox: {
                feature: {
                    saveAsImage: {}
                }
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: data['day_list']
            },
            yAxis: {
                type: 'value'
            },
            series: [
             {
                    name: '新增治愈',
                    type: 'line',
                    stack: '新增治愈',
                    data: data['add_heal_list'],
                    smooth: true,
                    color: 'green',
                    lineStyle: {
                        width: 3,
                        shadowColor: 'rgba(0,0,0,0.4)',
                        shadowBlur: 10,
                        shadowOffsetY: 10
                    },
                },

             {
                    name: '新增死亡',
                    type: 'line',
                    stack: '新增死亡',
                    data: data['add_dead_list'],
                    smooth: true,
                    color: 'pink',
                    lineStyle: {
                        width: 3,
                        shadowColor: 'rgba(0,0,0,0.4)',
                        shadowBlur: 10,
                        shadowOffsetY: 10
                    },
                },
                {
                    name: '新增确诊',
                    type: 'line',
                    stack: '新增确诊',
                    data: data['add_confirm_list'],
                    smooth: true,
                    color: 'red',
                    lineStyle: {
                        width: 3,
                        shadowColor: 'rgba(0,0,0,0.4)',
                        shadowBlur: 10,
                        shadowOffsetY: 10
                    },
                },
                {
                    name: '新增疑似',
                    type: 'line',
                    stack: '新增疑似',
                    data: data['add_suspect_list'],
                    smooth: true,
                    color: '#ffd661',
                    lineStyle: {
                        width: 3,
                        shadowColor: 'rgba(0,0,0,0.4)',
                        shadowBlur: 10,
                        shadowOffsetY: 10
                    },
                }
            ]
        };
            add_data_report.setOption(option)

    });
    let myChart = echarts.init(document.getElementById("report_area"));

    // 动态获取疫情地图数据并渲染报表
    $.get('/get_province_data/',function(data){
            let option = {
            tooltip: {
                    formatter:function(params,ticket, callback){
                        return params.seriesName+'<br />'+params.name+'：'+params.value
                    }//数据格式化
                },
            visualMap: {
                min: 0,
                max: 1000,
                left: 'left',
                top: 'bottom',
                text: ['高','低'],//取值范围的文字
                // categories: ['1000', '2000', '3000'],
                inRange: {
                    color: ['#ffefd7', '#ffd2a0', '#fe8664', '#e64b47', '#c91014', '#9c0a0d']//取值范围的颜色
                },
                show:true//图注
            },
            geo: {
                map: 'china',
                roam: false,//不开启缩放和平移
                zoom:1.23,//视角缩放比例
                label: {
                    normal: {
                        show: true,
                        fontSize:'10',
                        color: 'rgba(0,0,0,0.7)'
                    }
                },
                itemStyle: {
                    normal:{
                        borderColor: 'rgba(0, 0, 0, 0.2)'
                    },
                    emphasis:{
                        areaColor: '#F3B329',//鼠标选择区域颜色
                        shadowOffsetX: 0,
                        shadowOffsetY: 0,
                        shadowBlur: 20,
                        borderWidth: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            },
            series : [
                {
                    name: '累计确诊',
                    type: 'map',
                    geoIndex: 0,
                    data: data['data_list']
                }
            ]
        };

       myChart.setOption(option)
    });


</script>
</body>
</html>